<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Clojure documentation browser</title><style>
.library
{
  padding: 0.5em 0 0 0 
}
.all-libs-toggle,.library-contents-toggle
{
 font-size: small;
}
.all-libs-toggle a,.library-contents-toggle a
{
 color: white
}
.library-member-doc-whitespace
{
 white-space: pre
}
.library-member-source-toggle
{
  font-size: small;
  margin-top: 0.5em
}
.library-member-source
{
  display: none;
  border-left: solid lightblue 
}
.library-member-docs
{
  font-family:monospace
}
.library-member-arglists
{
  font-family: monospace
}
.library-member-type
{
  font-weight: bold; 
  font-size: small;
  font-style: italic;
  color: darkred
}
.lib-links
{
  margin: 0 0 1em 0
}

.lib-link-header
{
  color: white;
  background: darkgreen;
  width: 100%
}

.library-name 
{ 
  color: white;
  background: darkblue;
  width: 100%
}

.missing-library
{
  color: darkred; 
  margin: 0 0 1em 0 
}

.library-members
{
  list-style: none
}

.library-member-name
{
  font-weight: bold;
  font-size: 105%
}</style><script language="JavaScript" type="text/javascript"> // <![CDATA[

function getElem(id)
{
  if( document.getElementById )
  {
    return document.getElementById( id )
  }
  else if ( document.all )
  {
    return eval( 'document.all.' + id )
  }
  else
    return false;
}

function setDisplayStyle(id,displayStyle)
{
  var elem = getElem (id)
  if (elem)
  {
    elem.style.display = displayStyle
  }

}

function setLinkToggleText (id, text)
{
 var elem = getElem (id)
 if (elem)
 {
   elem.innerHTML = text
 }
}

function collapse(id)
{
  setDisplayStyle (id, 'none')
}

function expand (id)
{
  setDisplayStyle (id, 'block')
}

function toggleSource( id )
{
  toggle(id, 'linkto-' + id, 'Hide Source', 'Show Source')
}

function toggle(targetid, linkid, textWhenOpen, textWhenClosed)
{
  var elem = getElem (targetid)
  var link = getElem (linkid)

  if (elem && link)
  {
    var isOpen = false
    if (elem.style.display == '')
    {
      isOpen = link.innerHTML == textWhenOpen
    }
    else if( elem.style.display == 'block' )
    {
      isOpen = true
    }
    
    if (isOpen)
    {
      elem.style.display = 'none'
      link.innerHTML = textWhenClosed
    }
    else
    {
      elem.style.display = 'block'
      link.innerHTML = textWhenOpen
    }
  }
}

      //]]>
</script><script language="JavaScript" type="text/javascript">// <![CDATA[!
function expandAllNamespaces()
{
expand(&apos;library-contents-server.server&apos;);
setLinkToggleText(&apos;library-contents-toggle-server.server&apos;, &apos;-&apos;);

}function collapseAllNamespaces()
{
collapse(&apos;library-contents-server.server&apos;);
setLinkToggleText(&apos;library-contents-toggle-server.server&apos;, &apos;+&apos;);

}
// ]]></script></head><body><div class="lib-links"><div class="lib-link-header">Namespaces<span class="all-libs-toggle"> [ <a href="javascript:expandAllNamespaces()">Expand All</a> ] [ <a href="javascript:collapseAllNamespaces()">Collapse All</a> ]</span></div><a class="lib-link" href="#library-server.server">server.server</a></div><div class="library"><a name="library-server.server"/><div class="library-name"><span class="library-contents-toggle">[ <a id="library-contents-toggle-server.server" href="javascript:toggle(&apos;library-contents-server.server&apos;, &apos;library-contents-toggle-server.server&apos;, &apos;-&apos;, &apos;+&apos;)">-</a> ] </span>server.server</div><div class="library-contents" id="library-contents-server.server"><div class="library-member-links"><a class="lib-member-link" href="#member-server.server-connect-test">connect-test</a> <a class="lib-member-link" href="#member-server.server-create">create</a> <a class="lib-member-link" href="#member-server.server-create-net-send">create-net-send</a> <a class="lib-member-link" href="#member-server.server-delete">delete</a> <a class="lib-member-link" href="#member-server.server-delete-net-send">delete-net-send</a> <a class="lib-member-link" href="#member-server.server-describe">describe</a> <a class="lib-member-link" href="#member-server.server-describe-net-send">describe-net-send</a> <a class="lib-member-link" href="#member-server.server-hashDB">hashDB</a> <a class="lib-member-link" href="#member-server.server-manager">manager</a> <a class="lib-member-link" href="#member-server.server-out-of-date">out-of-date</a> <a class="lib-member-link" href="#member-server.server-out-of-date-net-send">out-of-date-net-send</a> <a class="lib-member-link" href="#member-server.server-route">route</a> <a class="lib-member-link" href="#member-server.server-select">select</a> <a class="lib-member-link" href="#member-server.server-select-net-send">select-net-send</a> <a class="lib-member-link" href="#member-server.server-serialize">serialize</a> <a class="lib-member-link" href="#member-server.server-server-start">server-start</a> <a class="lib-member-link" href="#member-server.server-update">update</a> <a class="lib-member-link" href="#member-server.server-update-net-send">update-net-send</a></div><ol class="library-members"><li class="library-member"><a name="member-server.server-connect-test"/><dl class="library-member-table"><dt class="library-member-name">connect-test</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([input output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Permits to check the connection</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-connect-test&apos;)" id="linkto-membersource-server.server-connect-test">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-connect-test"><pre>(defn connect-test
  &quot;Permits to check the connection&quot;
  [input output]   
    (.println output &quot;if you see this, the connection is working&quot;)
    (.flush output))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-create"/><dl class="library-member-table"><dt class="library-member-name">create</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database data])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets the data from the client and pass it to the database manager to create a new record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-create&apos;)" id="linkto-membersource-server.server-create">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-create"><pre>(defn create
  &quot;Gets the data from the client and pass it to the database manager to create a new record&quot;
  [database data]
  (create-record (.concat route (.concat database &quot;.db&quot;)) data))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-create-net-send"/><dl class="library-member-table"><dt class="library-member-name">create-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([data output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">creates a record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-create-net-send&apos;)" id="linkto-membersource-server.server-create-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-create-net-send"><pre>(defn create-net-send
  &quot;creates a record&quot;
  [data output]
  (let [[database dict] (read-string data)]
    (create database dict)
    )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-delete"/><dl class="library-member-table"><dt class="library-member-name">delete</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database RecNo])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets the record to delete from the client and pass it to the database manager to delete a record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-delete&apos;)" id="linkto-membersource-server.server-delete">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-delete"><pre>(defn delete
  &quot;Gets the record to delete from the client and pass it to the database manager to delete a record&quot;
  [database RecNo]
  (delete-record (.concat route (.concat database &quot;.db&quot;)) RecNo))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-delete-net-send"/><dl class="library-member-table"><dt class="library-member-name">delete-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([data output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">deletes a record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-delete-net-send&apos;)" id="linkto-membersource-server.server-delete-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-delete-net-send"><pre>(defn delete-net-send
  &quot;deletes a record&quot;
  [data output]
  (let [[database recno] (read-string data)]
    (delete database recno)
    )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-describe"/><dl class="library-member-table"><dt class="library-member-name">describe</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Returns the caracteristics of a database, in the number of fields, names of fields, and number of records that are not deleted.</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-describe&apos;)" id="linkto-membersource-server.server-describe">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-describe"><pre>(defn describe
  &quot;Returns the caracteristics of a database, in the number of fields, names of fields, and number of records that are not deleted.&quot;
  [database]
  (let [file-name (.concat route (.concat database &quot;.db&quot;))
	number (get-fields-number file-name)
	fields (get-fields-names file-name)
	records (records-number-not-deleted file-name)]
    (conj [] number fields records)))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-describe-net-send"/><dl class="library-member-table"><dt class="library-member-name">describe-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Performs a describe in the DB and sends it through the socket</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-describe-net-send&apos;)" id="linkto-membersource-server.server-describe-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-describe-net-send"><pre>(defn describe-net-send
  &quot;Performs a describe in the DB and sends it through the socket&quot;
  [database output]
    (let [fields (serialize (describe database))]
      (.println output fields)
    )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-hashDB"/><dl class="library-member-table"><dt class="library-member-name">hashDB</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Calculate the md5 one way hash of the database</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-hashDB&apos;)" id="linkto-membersource-server.server-hashDB">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-hashDB"><pre>(defn hashDB
  &quot;Calculate the md5 one way hash of the database&quot;
  [database]
  (let [md (doto (MessageDigest/getInstance &quot;MD5&quot;))]
    (.update md (.getBytes (serialize (select database))))
    (let [result (.digest md)]
     (str-join &quot;&quot; (map #(Integer/toHexString (bit-and % 0xff)) result)))))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-manager"/><dl class="library-member-table"><dt class="library-member-name">manager</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([_ socket])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Manages the petitions from the client, so it executes the correct operation</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-manager&apos;)" id="linkto-membersource-server.server-manager">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-manager"><pre>(defn manager
  &quot;Manages the petitions from the client, so it executes the correct operation&quot;
  [_ socket]
  (with-open [input (BufferedReader. (InputStreamReader. (.getInputStream socket)))
	      output (PrintWriter. (.getOutputStream socket))]
    (let [database (.readLine input)
	  action (.readLine input)]
      (when (.equals action &quot;test&quot;)
	(.flush output)
	(connect-test input output))
      (when (.equals action &quot;describe&quot;)
	(.flush output)
	(describe-net-send database output))
      (when (.equals action &quot;select&quot;)
	(.flush output)
	(select-net-send database output))
      (when (.equals action &quot;update&quot;)
	(.flush output)
	(update-net-send database output))
      (when (.equals action &quot;create&quot;)
	(.flush output)
	(create-net-send database output))
      (when (.equals action &quot;delete&quot;)
	(.flush output)
	(delete-net-send database output))
      (when (.equals action &quot;out-of-date&quot;)
	(.flush output)
	(out-of-date-net-send database output))
	

)))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-out-of-date"/><dl class="library-member-table"><dt class="library-member-name">out-of-date</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database hashRec])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Checks with the client, if it is out of date or can proceed</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-out-of-date&apos;)" id="linkto-membersource-server.server-out-of-date">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-out-of-date"><pre>(defn out-of-date
  &quot;Checks with the client, if it is out of date or can proceed&quot;
  [database hashRec]
  (if (.equals hashRec (hashDB database))
    &quot;up-to-date&quot;
    &quot;out-of-date&quot;))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-out-of-date-net-send"/><dl class="library-member-table"><dt class="library-member-name">out-of-date-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([data output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Sends the result of the out-of-date check to the client</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-out-of-date-net-send&apos;)" id="linkto-membersource-server.server-out-of-date-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-out-of-date-net-send"><pre>(defn out-of-date-net-send
  &quot;Sends the result of the out-of-date check to the client&quot;
  [data output]
  (let [[database hashRec] (read-string data)]
    (.println output (out-of-date database hashRec))
    (.flush output)))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-route"/><dl class="library-member-table"><dt class="library-member-name">route</dt><dd><div class="library-member-info"><span class="library-member-type">var</span> <span class="library-member-arglists"></span></div><div class="library-member-docs"/><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-route&apos;)" id="linkto-membersource-server.server-route">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-route"><pre>(def route &quot;./&quot;)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-select"/><dl class="library-member-table"><dt class="library-member-name">select</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets all the records that are not deleted to the client</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-select&apos;)" id="linkto-membersource-server.server-select">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-select"><pre>(defn select
  &quot;Gets all the records that are not deleted to the client&quot;
  [database]
  (read-records-not-deleted (.concat route (.concat database &quot;.db&quot;))))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-select-net-send"/><dl class="library-member-table"><dt class="library-member-name">select-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">sends the records</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-select-net-send&apos;)" id="linkto-membersource-server.server-select-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-select-net-send"><pre>(defn select-net-send
  &quot;sends the records&quot;
  [database output]
  (let [records (serialize (select database))]
    (.println output records)
    (.flush output)
    )
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-serialize"/><dl class="library-member-table"><dt class="library-member-name">serialize</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([data])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Converts structures into strings</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-serialize&apos;)" id="linkto-membersource-server.server-serialize">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-serialize"><pre>(defn serialize
	&quot;Converts structures into strings&quot;
	[data]
	(binding[*print-dup* true]
  		(print-str data))
)</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-server-start"/><dl class="library-member-table"><dt class="library-member-name">server-start</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([port])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Make the server start attending the connections</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-server-start&apos;)" id="linkto-membersource-server.server-server-start">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-server-start"><pre>(defn server-start
  &quot;Make the server start attending the connections&quot;
  [port]
  (let [server (ServerSocket. port)
	agent (agent nil)]
	(println &quot;To abort the server, Ctrl+C&quot;)
    (loop []
      (println &quot;Waiting for connections&quot;)
      (let [socket (.accept server)]
	(send-off agent manager socket))
	(recur))))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-update"/><dl class="library-member-table"><dt class="library-member-name">update</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([database RecNo data])</span></div><div class="library-member-docs"><div class="library-member-doc-line">Gets the record to update from the client and pass it to the database manager to update a record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-update&apos;)" id="linkto-membersource-server.server-update">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-update"><pre>(defn update
  &quot;Gets the record to update from the client and pass it to the database manager to update a record&quot;
  [database RecNo data]
  (update-record (.concat route (.concat database &quot;.db&quot;)) RecNo data))</pre></div></div></dd></dl></li><li class="library-member"><a name="member-server.server-update-net-send"/><dl class="library-member-table"><dt class="library-member-name">update-net-send</dt><dd><div class="library-member-info"><span class="library-member-type">fn</span> <span class="library-member-arglists">([data output])</span></div><div class="library-member-docs"><div class="library-member-doc-line">updates the record</div></div><div class="library-member-source-section"><div class="library-member-source-toggle">[ <a href="javascript:toggleSource(&apos;membersource-server.server-update-net-send&apos;)" id="linkto-membersource-server.server-update-net-send">Show Source</a> ]</div><div class="library-member-source" id="membersource-server.server-update-net-send"><pre>(defn update-net-send
  &quot;updates the record&quot;
  [data output]
  (let [[database num dict] (read-string data)]
    (update database num dict)
   )
)</pre></div></div></dd></dl></li></ol></div></div></body></html>